package com.sg.business.commons.labelprovider.project;

import org.eclipse.jface.viewers.ColumnLabelProvider;

import com.mobnut.db.model.PrimaryObject;
import com.mongodb.DBObject;
import com.sg.business.model.WorkOrderDetail;

public class DepartmentLabelProvider extends ColumnLabelProvider {

	@Override
	public String getText(Object element) {
		if (element instanceof WorkOrderDetail) {
				WorkOrderDetail workOrder = (WorkOrderDetail) element;
				String code = workOrder.getDepartmentCode();
				Object value = workOrder
						.getValue("projectdepartment");
				if (value != null) {
					DBObject dbo = (DBObject)value;
					String label = (String)dbo.get(PrimaryObject.F_DESC);
					return "[" + code + "]" + label;
						}
				}
		return "";
	}
}
